package com.prothink.threadproject.util;

import java.awt.*;
import java.awt.image.BufferedImage;

public class ChaptchaUtil {
    /**
     * 生成验证码图片
     * @return
     */
    public static BufferedImage generatorCode(String account){
        //把验证码放到缓存
        String code = PwdUtil.generatorPassword();
        CacheUitl.putValue(account,code,600);
        //生成验证码图片
        BufferedImage image = new BufferedImage(300, 70, BufferedImage.TYPE_INT_RGB);
        Graphics g = image.getGraphics();
        g.setColor(Color.WHITE);
        g.fillRect(0, 0, 300, 70);
        g.setColor(Color.BLACK);
        g.setFont(new Font("Arial", Font.PLAIN, 30));
        g.drawString(PwdUtil.generatorPassword(), 10, 30);
        return image;
    }
}
